<template>
  <div class="checkExamBody">
    <div>
      <div class="top">
        <span>试题详情</span>
        <el-icon class="icon" @click="closure"><Close /></el-icon>
      </div>
    </div>
    <!-- 题的类型 -->
    <div class="type">
      <span>{{ dataLook.type }}</span>
      <span class="fraction">分值：{{ dataLook.scores }}</span>
    </div>
    <div class="title" v-html="dataLook.title"></div>
    <!-- 选项 -->
    <div
      class="chooses"
      v-show="dataLook.type === '单选题' || dataLook.type === '多选题'"
    >
      <!-- chooseed   选中 -->
      <div
        v-show="dataLook.type === '单选题'"
        :class="
          dataLook.answer === item.answerno ? 'choose chooseed' : 'choose'
        "
        v-for="item in dataLook.answers"
        :key="item.id"
      >
        <div class="box"></div>
        <div class="cho">{{ item.answerno }}：{{ item.content }}</div>
      </div>
      <div
        v-show="dataLook.type === '多选题'"
        :class="
          dataLook.answer.split('|').includes(item.answerno)
            ? 'choose chooseed'
            : 'choose'
        "
        v-for="item in dataLook.answers"
        :key="item.id"
      >
        <div class="box"></div>
        <div class="cho">{{ item.answerno }}：{{ item.content }}</div>
      </div>
    </div>
    <!-- 判断题  填空题  问答题-->
    <div
      class="isBox"
      v-show="
        dataLook.type === '判断题' ||
        dataLook.type === '填空题' ||
        dataLook.type === '问答题'
      "
    >
      <div class="is" v-show="dataLook.type !== '问答题'">
        <span>正确答案</span>
        <span>{{ dataLook.answer }}</span>
      </div>
    </div>
    <div
      class="parseBox"
      v-show="dataLook.type === '填空题' || dataLook.type === '问答题'"
    >
      <div class="parse">
        <span>答案解析</span>
        <span>{{ dataLook.explains }}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {
  reactive,
  toRefs,
  inject
} from "vue";
import { Close } from "@element-plus/icons-vue";
// 响应式数据
const data: any = reactive({
  isLook: false,
  dataLook: {},
});
// ref解构数据
const { isLook, dataLook } = toRefs(data);
// 父共享的数据
const datas: any = inject("data");
// 是否打开
data.isLook = datas.isLook;
// 回显数据
data.dataLook = datas.dataUp;
// 关闭
const closure = () => {
  datas.isLook = false;
};
</script>

<style lang="less" scoped>
@import url("../../static/css/databaselist/checkExam.css");
</style>
